<template>
	<el-container>
		<el-aside>
			<a-left :data="ldata"></a-left>
		</el-aside>

		<el-aside>
			<a-rigft :data="rdata" @callOut="onCall"></a-rigft>
		</el-aside>
	</el-container>
</template>

<script setup>
import {
	computed,
	watch,
	ref,
	onUnmounted,
	onMounted,
	nextTick,
	toRefs,
} from "vue";

import {
	useStore
} from "vuex";
import aLeft from "./left.vue"
import aRigft from "./right.vue"
const cams = ref([]);
const store = useStore();
const {
	scene3d,
	asideWidth,
	spaceComd,
	year,
	devIcons
} = toRefs(store.state);

//1.模型models,2.模型类型modelsType
const {
	datMods,
	datModsType
} = toRefs(store.state.s3d);

// const {
// } = 
const ldata = ref({});
const rdata = ref({});

const emits = defineEmits(["call"]);
const hCallOut = (h, d) => {
	emits("call", h, d);
}
watch([year, spaceComd], o => {
	refData(o[1], o[0]);
});
const onCall = (h, d) => {
	//	console.log("on call", h, d);
	switch (h) {
		case "hDevInfo":
			//电设备详情

			console.log("get devInfo", d);
			return;
			break;
		case "hAlrmInfo": //告警信息
			hCallOut(h, d);
			break;
		case "hToFlo":

			break;
		default:
			hCallOut(h, d);
			break;
	}
}

let wh = -1;
const refData = (sp, y) => {
	if (!sp.id) {
		return;
	}
	clearTimeout(wh);
	wh = setTimeout(() => {
		//console.log("空间切换", sp, y);
		// var sortList = [];
		// for (var i = 0; i < 1000; i++) {
		// 	sortList.push({
		// 		"sort": i,
		// 		"name": "xxx_" + i,
		// 		"ydl": (Math.random() * 100).toFixed(2),
		// 		"zhnh": (Math.random() * 100).toFixed(2),
		// 		"tpf": (Math.random() * 100).toFixed(2)
		// 	})
		// }
		// console.log(sortList);
		// rdata.value.sortList = sortList;
		// return;


		console.log("空间切换数据 刷新", JSON.stringify(sp), y);
		let spId = sp.id;


	}, 100);
}


const hk = ref(null),
	ws = ref(null),
	onPlayCam = d => {
		hk.value.call.play(d.code, d.name);
		console.log("play", d);
	},
	hRefIndexDat = () => {
		refData(spaceComd.value, year.value);
		// door.getList().then(r => {
		// 	console.log("doors", r);
		// })
	};

watch(datMods, (dms) => {
	console.log("所有模型", dms.length);
	dats.value[2] = hEitem("3D模型数量", "3dmod", dms.length);
});
onMounted(() => {
	nextTick(() => {
		setTimeout(() => {
			hRefIndexDat();
		}, 50);
	})
}
);
</script>

<style scoped lang="scss">
.el-aside {
	// margin-right: 29px;
	// width: 392px;
	padding: 0 0 0 0;
	/* Set a fixed width */
}

/* Additional styles */
div[class^="screenNum"] {
	background-size: auto 80%;
	width: 100%;
	height: 50%;
	background-repeat: no-repeat;
	background-position: center;
}
</style>